
uniform sampler2D		bumpMap;
uniform sampler2D		currentRender;

uniform vec2		xyScale;			// Passed in automatically
uniform vec2		potAdjust;			// Passed in automatically

varying vec2		bumpTexCoord;
varying float		deformScale;


void main (void){

	vec3		normalVec;
	vec3		color;
	vec2		texCoord;

	// Load the normal vector from the bump map
	normalVec = texture2D(bumpMap, bumpTexCoord).rgb * 2.0 - 1.0;
	normalVec = normalize(normalVec);

	// Load the current render with a modified texcoord
	texCoord = (gl_FragCoord.xy * xyScale) + (normalVec.xy * deformScale);
	texCoord = clamp(texCoord, 0.0, 1.0) * potAdjust;

	color = texture2D(currentRender, texCoord).rgb;

	// Write the final color
	gl_FragColor = vec4(color, 1.0);
}
